Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

302
Views
SpringBoot MongoDB returns "Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable"

I tried adding a new collection to my API/DB today, and when I try to POST or GET, I get this 500 error response:

{
  "cause": null,
  "message": "Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable"
}

However the POST is actually successful, I can see the new data in the DB.

Model:

@Setter
@Getter
public class League {

    private String name;
    private String shortName;
    private List<Team> teams;
}

Repository:

@RepositoryRestResource(collectionResourceRel = "leagues", path = "leagues", excerptProjection = LeagueProjection.class)
public interface LeagueRepository extends MongoRepository<League, String> {

}

Projection:

@Projection(name="LeagueProjection", types={League.class})
public interface LeagueProjection {

    String getName();
    String getShortName();
}

I am not doing anything special. I have multiple other collections that work fine.

I am using spring-boot 1.5.1.

Thanks!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Adding the field:

@Id private String id;

to my model seems to have resolved the issue.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!